import 'package:flutter/material.dart';
import 'package:frametrim/activity/facecheckPage.dart';
import 'package:frametrim/activity/loginPage.dart';
import 'package:frametrim/activity/mainPage.dart';
import 'package:frametrim/activity/registerPage.dart';
import 'package:frametrim/activity/salaryDetailPage.dart';
import 'package:frametrim/activity/salaryFeedbackPage.dart';
import 'package:frametrim/activity/salaryRecordsPage.dart';
import 'package:frametrim/activity/salarySurePage.dart';
import 'package:frametrim/activity/systemPage.dart';
import 'package:frametrim/appviews/web_scene.dart';
import 'package:frametrim/appviews/web_scene_notitle.dart';
/*页面跳转工具类*/

class AppNavigator {
  static push(BuildContext context, Widget scene) {
    //跳转
    Navigator.push(
      context,
      MaterialPageRoute(
        builder: (BuildContext context) => scene,
      ),
    );
  }

  /* 跳转到起始页并关闭所有页面*/
  static pushAndRemove(BuildContext context, Widget scene) {
    Navigator.pushAndRemoveUntil(
      context,
      new MaterialPageRoute(builder: (context) => scene),
      (route) => route == null,
    );
  }

  //设置某页面SingleTask
  static pushSingleTaskAndRemove(BuildContext context, Widget scene){
/*
    ///这里是将OldTellPage 设置为SingleTask
    Navigator.push(context, MaterialPageRoute(
        settings: RouteSettings(name: scene.Tag),
        builder: (context){
          return scene;
        }));*/
  }

  /**
   * 同时销毁多个页面
   */

  /*方法一：把入栈的路由设置姓名，便于同时销毁多个页面  想回到哪个页面就给哪个页面设置name*/
  static pushWithName(BuildContext context, Widget scene, String name1) {
    Navigator.push(
      context,
      MaterialPageRoute(
        builder: (context) => scene,
        settings: RouteSettings(name: name1),
      ),
    );
  }

  /*一次回退多个页面 根据name回退至指定页面*/
  static popWithName(BuildContext context, String name) {
    Navigator.popUntil(context, ModalRoute.withName(name));
  }

  /*退出当前页面*/
  static popPage(BuildContext context, Widget scene) {
    Navigator.pop(context, scene);
  }

  //跳转注册
  static pushToRegister(BuildContext context) {
    AppNavigator.push(context, RegisterPage());
  }

  //跳转登录
  static pushToLogin(BuildContext context) {
    AppNavigator.push(context, LoginPage());
  }

  //跳转主页
  static pushToMain(BuildContext context) {
    AppNavigator.push(context, MainPage());
  }

  //跳转人脸核验
  static pushToFaceCheck(BuildContext context) {
    AppNavigator.push(context, FaceCheckPage());
  }

  //跳转设置
  static pushToSystem(BuildContext context) {
    AppNavigator.push(context, SystemPage());
  }

  //跳转工资确认列表
  static pushToSalarySure(BuildContext context) {
    AppNavigator.push(context, SalarySurePage());
  }

  //跳转工资条详情
  static pushToSalaryDetails(BuildContext context, String id) {
    AppNavigator.push(context, SalaryDetailsPage(id));
  }

  //跳转工资核对记录
  static pushToSalaryRecords(BuildContext context, String id) {
    AppNavigator.push(context, SalaryRecordsPage(id));
  }

  //跳转工资反馈
  static pushToSalaryFeedBack(BuildContext context, String id) {
    AppNavigator.push(context, SalaryFeedBackPage(id));
  }

  static pushWeb(BuildContext context, String url) {
    Navigator.push(context, MaterialPageRoute(builder: (context) {
      return WebSceneNoTitle(url: url);
    }));
  }

  /*添加的有app Title*/
  static pushWeb1(BuildContext context, String url, String name) {
    Navigator.push(context, MaterialPageRoute(builder: (context) {
      return WebScene(
        url: url,
        name: name,
      );
    }));
  }
}
